package com.simple.datax.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.simple.util.common.Constants;
import com.simple.util.common.XSSUtil;

@Controller
public class AlertMessageController extends AbstractDataxBaseController{
	private final static String JSP_PATH = "_AlertMessage";
	@RequestMapping("/alertMessage")
	public String init(final HttpServletRequest request, final HttpServletResponse response) {
		
		String errorId = request.getParameter("errorId");
        if(errorId==null){
            errorId = "";
        }
        String arguments = request.getParameter("arguments");
        if(arguments==null){
            arguments = "";
        }
        
        String goPage = request.getParameter("goPage");
        if(goPage==null){
            goPage = Constants.SYSTEM_ALERT_GOPAGE_HOME;
        }
        goPage = goPage.replaceAll("\\"+Constants.SPLIT_URL_ADDRESS, "&");
        goPage = XSSUtil.javaScriptEncode(goPage);
        
        request.setAttribute("errorId", errorId);
        request.setAttribute("arguments", arguments);
        request.setAttribute("goPage", goPage);
        request.setAttribute("SYSTEM_ALERT_GOPAGE_BACK", Constants.SYSTEM_ALERT_GOPAGE_BACK);
        request.setAttribute("SYSTEM_ALERT_GOPAGE_HOME", Constants.SYSTEM_ALERT_GOPAGE_HOME);
        request.setAttribute("SYSTEM_ALERT_GOPAGE_CLOSE", Constants.SYSTEM_ALERT_GOPAGE_CLOSE);
        request.setAttribute("SYSTEM_ALERT_GOPAGE_LOGOUT", Constants.SYSTEM_ALERT_GOPAGE_LOGOUT);

		
        return getJspPath("alert");
    }
	@Override
    protected String getBaseJspPath() {
        return JSP_PATH;
    }
}
